import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import stores, {useStore} from './stores'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import config from './config/index'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

import XComponent from '@/components'
const app = createApp(App);
app.config.globalProperties.publicPath = import.meta.env.BASE_URL;
app.use(ElementPlus,{locale: zhCn});
app.use(XComponent,{componentImport: config.componentImport});
app.use(stores);

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}

import Core from '@/core';
import constant from './util/const';
app.use(Core, {config, useStore, constant})
import Directive from '@/core/directive';
app.use(Directive)

router.init(useStore, () => {
    app.use(router);
    window['$app'] = app;
    window['$router'] = router;
    app.mount('#app');
});
